
//判断图片是否损坏
function imgError(){ 
    var img = event.srcElement; 
    img.src = "https://mms0.baidu.com/it/u=1402893264,594888051&fm=15&gp=0.jpg&fmt=auto";
    img.onerror = null; //控制不要一直跳动 
}
window.onresize = function(){
    var win_width=document.documentElement.clientWidth;
    if(win_width <= 1662){
        $('.down_right').css({
            'right':'1.5%'
        })
    }else{
        $('.down_right').css({
            'right':'9%'
        })
    }
};
$(window).scroll(function(){ 
    if($(window).scrollTop() >= 215){
        $('.down_right').css({
            'position':'fixed',
            'top':'0px',
        })
    }else{
        $('.down_right').css({
            'position':'absolute',
            'top':'216px'
        })
    }
});


//底部悬浮
scroll()
function scroll(){
    //给div绑定一个scroll事件
    $(window).bind('scroll',function(){
        var scrollVal = $(window).scrollTop();
        if (scrollVal > 700) {
            $('.footer_xf').show(100);
        }else if(scrollVal == 0){
            $('.footer_xf').hide(100);
        }
    })

}
var num = 0;
//出现弹窗
$('body').on('click','.all_btn',function(){
    setTimeout(function(){
        $('.popup_wrap').show()
    },1500)
})
//关闭
$('body').on('click','.popup_top span',function(){
    $(this).parent().parent().hide()
    num=1;
})
 //轮播图
$(".box").superSlider({
    prevBtn: 	 ".prev",//左按钮
    nextBtn: 	 ".next",//右按钮
    listCont:    "#roll",//滚动列表外层
    scrollWhere: "prev",//自动滚动方向next
    delayTime: 	 1000,//自动轮播时间间隔
    speed: 		 300,//滚动速度
    amount: 	 1,//单次滚动数量
    showNum: 	 6,//显示数量
    autoPlay: 	 false//自动播放
});



//搜索
$('body').on('click','.header_ipt',function(){
    $(this).val('')
})
$('body').on('click','.header_btn',function(){
    var text = $('.header_ipt').val();
    var url_str = "/index/search/index?keyword="+text;
    window.open(url_str);
})
//回车事件绑定
$('.header_ipt').bind('keyup', function(event) {
    if (event.keyCode == 13) {
        var text = $(this).val();
        var url_str = "/index/search/index?keyword="+text;
        window.open(url_str);
    }
});

if($('.brief_text p').text().length >= 100){
    $('.brief_btn').show()
}else{
    $('.brief_btn').hide()
}
//点击展开
$('.brief_text').click(function(){
    $('.brief_dt').hide()
    $('.brief_btn').hide()
    $(this).css({
        'margin-top':'0px',
        'height':'423px',
        'padding-bottom':'0px'
    })
    $(this).find('.brief_Off').show()
    $(this).find('p').css({
        '-webkit-line-clamp':'inherit'
    })
})
//点击收
$('body').on('click','.brief_Off',function(){
    $(this).hide()
    $('.brief_dt').show()
    $(this).parent().find('.brief_btn').show()
    $(this).parent().css({
        'margin-top':'10px',
        'height':'auto',
        'padding-bottom':'10px'
    })
    $(this).parent().find('p').css({
        '-webkit-line-clamp':'2'
    })
})
//判断鼠标是否在动
function ScreenSaver(settings) {

    this.settings = settings;

    this.nTimeout = this.settings.timeout;

    document.body.screenSaver = this;
    // link in to body events
    document.body.onmousemove = ScreenSaver.prototype.onevent;
    document.body.onmousedown = ScreenSaver.prototype.onevent;
    document.body.onkeydown = ScreenSaver.prototype.onevent;
    document.body.onkeypress = ScreenSaver.prototype.onevent;
    document.body.onmousewheel = ScreenSaver.prototype.onevent;
    // document.body.onscroll = ScreenSaver.prototype.onevent;

    var pThis = this;
    var f = function () {
        pThis.timeout();
    }
    this.timerID = window.setTimeout(f, this.nTimeout);
}
ScreenSaver.prototype.timeout = function () {
    if (!this.saver) {
            num+=1
        if(num == 1){
            $('.popup_wrap').show()
        }
        
    }
}
ScreenSaver.prototype.signal = function () {
    if (this.saver) {
        this.saver.stop();
    }

    window.clearTimeout(this.timerID);
    var pThis = this;
    var f = function () {
        pThis.timeout();
    }
    this.timerID = window.setTimeout(f, this.nTimeout);
}
ScreenSaver.prototype.onevent = function (e) {
    this.screenSaver.signal();
}
var saver;
function initScreenSaver() {
    //blort;
    saver = new ScreenSaver({timeout: 15000});   //页面鼠标十秒内不动
}
initScreenSaver()
